<?php
class BrandCheck extends Check {
    public function addCheck(Model $model,Array $condition) {
        if(self::isNullString($_POST['name'])) {
            $this->flag = false;
            $this->message[] = '品牌名称不能为空!';
        }
        if(self::checkStrLength($_POST['name'],2,'min')) {
            $this->flag = false;
            $this->message[] = '品牌名称不能少于两位!';
        }
        if(self::checkStrLength($_POST['name'],20,'max')) {
            $this->flag = false;
            $this->message[] = '品牌名称不能大于二十位!';
        }
        if(self::checkStrLength($_POST['url'],200,'max')) {
            $this->flag = false;
            $this->message[] = '品牌官方网站不能大于两百位!';
        }
        if(self::checkStrLength($_POST['info'],200,'max')) {
            $this->flag = false;
            $this->message[] = '品牌简介不能大于两百位!';
        }
        if($model->isOne($condition)) {
            $this->flag = false;
            $this->message[] = '品牌名称已经被占用!';
        }
        return $this->flag;
    }
    public function updateCheck() {
        if(self::isNullString($_POST['name'])) {
            $this->flag = false;
            $this->message[] = '品牌名称不能为空!';
        }
        if(self::checkStrLength($_POST['name'],2,'min')) {
            $this->flag = false;
            $this->message[] = '品牌名称不能少于两位!';
        }
        if(self::checkStrLength($_POST['name'],20,'max')) {
            $this->flag = false;
            $this->message[] = '品牌名称不能大于二十位!';
        }
        if(self::checkStrLength($_POST['url'],200,'max')) {
            $this->flag = false;
            $this->message[] = '品牌官方网站不能大于两百位!';
        }
        if(self::checkStrLength($_POST['info'],200,'max')) {
            $this->flag = false;
            $this->message[] = '品牌简介不能大于两百位!';
        }
        return $this->flag;
    }
    public function ajaxCheckName(Model &$model,Array $condition) {
        echo $model->isOne($condition) ? 1 : 2;
    }


}


?>